import { Alova } from '@/utils/http/alova/index';

/**
 * @description: 申请教师身份
 */
export function applyLecturerApi(data) {
  return Alova.Post<InResult>('/system/web/lecturer/apply', data, {
    meta: {
      isReturnNativeResponse: true,
    },
  });
}

/**
 * @description: 所有课程列表
 */
export function getAllCourseList(params) {
  return Alova.Get<InResult>('/course/web', { params });
}

/**
 * @description: 我的课程列表
 */
export function getCourseListApi(params) {
  return Alova.Get<InResult>('/course/web/lecturer/list', { params });
}

/**
 * @description: 课程详情
 */
export function getCourseDetailApi(id) {
  return Alova.Get<InResult>('/course/web/' + id);
}

/**
 * @description: 新增课程
 */
export function saveCourseApi(data) {
  return Alova.Post<InResult>('/course/web/lecturer', data);
}

/**
 * @description: 修改课程
 */
export function updateCourseApi(data) {
  return Alova.Put<InResult>('/course/web/lecturer', data);
}

/**
 * @description: 删除课程
 */
export function deleteCourseApi(id) {
  return Alova.Delete<InResult>('/course/web/lecturer/' + id);
}

/**
 * @description: 获取审核结果
 */
export function getAuditResultApi() {
  return Alova.Get<InResult>('/system/web/lecturer/apply/status');
}

/**
 * @description: 我的章节列表
 */
export function getChapterListApi(params) {
  return Alova.Get<InResult>('/course/web/chapter/list', { params });
}

/**
 * @description: 章节详情
 */
export function getChapterDetailApi(id) {
  return Alova.Get<InResult>('/course/web/chapter/' + id);
}

/**
 * @description: 新增章节
 */
export function saveChapterApi(data) {
  return Alova.Post<InResult>('/course/web/chapter', data);
}

/**
 * @description: 修改章节
 */
export function updateChapterApi(data) {
  return Alova.Put<InResult>('/course/web/chapter', data);
}

/**
 * @description: 删除章节
 */
export function deleteChapterApi(id) {
  return Alova.Delete<InResult>('/course/web/chapter/' + id);
}

/**
 * @description: 评论列表
 */
export function getCommentListApi(params) {
  return Alova.Get<InResult>('/community/comment/list', { params });
}

/**
 * @description: 新增评论
 */
export function addCommonApi(data) {
  return Alova.Post<InResult>('/community/comment', data, {
    meta: {
      isReturnNativeResponse: true,
    },
  });
}

/**
 * @description: 删除章节
 */
export function deleteCommonApi(id) {
  return Alova.Delete<InResult>(
    '/community/comment/' + id,
    {},
    {
      meta: {
        isReturnNativeResponse: true,
      },
    }
  );
}

/**
 * @description: 点赞章节
 */
export function likeChapterApi(params) {
  return Alova.Post<InResult>(
    '/community/like',
    {},
    {
      meta: {
        isReturnNativeResponse: true,
      },
      params,
    }
  );
}

/**
 * @description: 订阅课程
 */
export function subscribeCourseApi(data) {
  return Alova.Post<InResult>('/course/web/subscribe', data, {
    meta: {
      isReturnNativeResponse: true,
    },
  });
}

/**
 * @description: 订阅课程
 */
export function subscribeCourseListApi(params) {
  return Alova.Post<InResult>(
    '/course/web/subscribe/user',
    {},
    {
      params,
    }
  );
}

/**
 * @description: 创建订单
 */
export function createPaymentOrder(params) {
  return Alova.Post<any>(
    '/order/create',
    {},
    {
      params,
    }
  );
}

/**
 * @description: 查询订单状态
 */
export function checkPaymentStatus(orderNo: string) {
  return Alova.Get<any>('/order/status/' + orderNo);
}

/**
 * @description: 保存视频播放进度
 */
export function saveVideoProgressApi(data) {
  return Alova.Post<InResult>('/course/watch/report', data, {
    meta: {
      isReturnNativeResponse: true,
    },
  });
}

/**
 * @description: 获取视频播放进度
 */
export function getVideoProgressApi(chapterId: string) {
  return Alova.Get<InResult>('/course/web/progress/' + chapterId);
}

/**
 * @description: 我的浏览记录
 */
export function getHistoryListApi(params) {
  return Alova.Get<InResult>('/course/watch/page', { params });
}

/**
 * @description: 我的消息列表
 */
export function getMessageListApi(params) {
  return Alova.Get<InResult>('/system/web/message/list', { params });
}

/**
 * @description: 获取各类型消息数量
 */
export function getMessageNumberApi() {
  return Alova.Get<InResult>('/system/web/message/unread-count-by-type');
}

/**
 * @description: 消息批量已读
 */
export function messageAllReadByTypeApi(type) {
  return Alova.Put<InResult>('/system/web/message/batch-read?type=' + type);
}

export function messageAllReadApi() {
  return Alova.Put<InResult>('/system/web/message/batch-read');
}

/**
 * @description: 消息批量删除
 */
export function messageAllDeleteApi() {
  return Alova.Delete<InResult>('/system/web/message/batch-delete');
}
